package test01;

// WordCountSystem.java - 主程序
public class WordCountSystem {
    public static void main(String[] args) {
        if (args.length < 1) {
            System.out.println("用法: java WordCountSystem <输入文件> [输出文件]");
            return;
        }

        String inputFile = args[0];
        String outputFile = args.length > 1 ? args[1] : null;

        // 创建过滤器
        InputFilter inputFilter = new InputFilter();
        ProcessFilter processFilter = new ProcessFilter();
        OutputFilter outputFilter = new OutputFilter(
                outputFile != null ? OutputFilter.OutputType.FILE : OutputFilter.OutputType.CONSOLE,
                outputFile
        );

        // 构建管道
        Pipeline pipeline = new Pipeline(inputFilter, processFilter, outputFilter);

        System.out.println("开始执行单词统计系统...");
        System.out.println("数据流: 文件读取 → 单词统计 → 结果输出");
        System.out.println("=====================================");

        // 执行管道
        pipeline.execute(inputFile);

        System.out.println("=====================================");
        System.out.println("单词统计系统执行完成");
    }
}